package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Add implements Ioperation{
    public void work(BookList booklist) {
        int pos = booklist.getCurrentSize();
        if(pos == booklist.getCount()){
            System.out.println("书架已满.......");
            return;
        }

        Scanner scan = new Scanner(System.in);
        Book tmp = new Book();

        System.out.println("请输入书的书名：");
        String bookName = scan.nextLine();
        tmp.setName(bookName);

        System.out.println("请输入书的作者：");
        String bookAuthor = scan.nextLine();
        tmp.setAuthor(bookAuthor);

        System.out.println("请输入书的类型：");
        String bookType = scan.nextLine();
        tmp.setType(bookType);

        System.out.println("请输入书的价格：");
        double price = scan.nextDouble();
        tmp.setPrice(price);

        booklist.setBooks(pos,tmp);
        booklist.setCurrentSize(pos + 1);
        System.out.println("新增成功！！！");
    }
}
